package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckSafe;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.query.user.SysTenantUserPageQuery;
import com.lcf.system.service.SysTenantUserService;
import com.lcf.system.vo.tenantUser.SysTenantUserPageVO;
import com.lcf.system.vo.tenantUser.SysTenantUserVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 租户-用户(SysTenantUser)表控制层
 *
 * @author lcf
 * @since 2025-03-02 23:00:38
 */
@Tag(name = "租户-用户")
@RestController
@RequestMapping("sysTenantUser")
public class SysTenantUserController {
    @Resource
    private SysTenantUserService sysTenantUserService;

    /**
     * 添加用户至租户
     */
    @Operation(summary = "添加用户至租户")
    @PostMapping("add/{mobile}")
    @SaCheckPermission("sysTenantUser:add")
    public void add(@PathVariable @Schema(description = "手机号") String mobile) {
        sysTenantUserService.add(mobile);
    }

    /**
     * 退出当前租户
     */
    @Operation(summary = "退出当前租户")
    @SaCheckSafe
    @DeleteMapping("quit")
    public void quit() {
        sysTenantUserService.quit();
    }

    /**
     * 踢出当前租户
     */
    @Operation(summary = "踢出当前租户")
    @SaCheckPermission("sysTenant:kickOut")
    @DeleteMapping("kickOut/{userId}")
    public void kickOut(@PathVariable @Schema(description = "用户ID") long userId) {
        sysTenantUserService.kickOut(userId);
    }

    /**
     * 租户分页查询用户
     */
    @Operation(summary = "租户分页查询用户")
    @SaCheckPermission("sysTenantUser:page")
    @GetMapping("page")
    public PageVO<SysTenantUserPageVO> page(SysTenantUserPageQuery query) {
        return sysTenantUserService.page(query);
    }

    /**
     * 查看用户信息
     */
    @Operation(summary = "查看用户信息")
    @SaCheckPermission("sysUser:getDetail")
    @GetMapping("{userId}")
    public SysTenantUserVO getDetail(@PathVariable @Schema(description = "用户id") long userId) {
        return sysTenantUserService.getDetail(userId);
    }
}
